"use strict";

/*
 * MikoPBX - free phone system for small business
 * Copyright © 2017-2023 Alexey Portnov and Nikolay Beketov
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with this program.
 * If not, see <https://www.gnu.org/licenses/>.
 */

/* global globalRootUrl, globalTranslate, globalWebAdminLanguage, sessionStorage */

/**
 * sidebarMenuShowActive object for managing the highlighting of the active sidebar menu item.
 * @module sidebarMenuShowActive
 */
var sidebarMenuShowActive = {
  /**
   * jQuery object for the sidebar menu.
   * @type {jQuery}
   */
  $sidebarMenu: $('#toc'),

  /**
   * Initializes the sidebar menu and sets the active menu item.
   */
  initialize: function initialize() {
    sidebarMenuShowActive.$sidebarMenu.sidebar('setting', 'transition', 'overlay');
    sidebarMenuShowActive.$sidebarMenu.sidebar('attach events', '#sidebar-menu-button');
    sidebarMenuShowActive.makeMenuActiveElement();
  },

  /**
   * Sets the active menu item in the sidebar based on the current URL.
   */
  makeMenuActiveElement: function makeMenuActiveElement() {
    var current = window.location.href;
    $.each($('.sidebar-menu a'), function (index, value) {
      var $this = $(value);
      $this.removeClass('active'); // if the current path is like this link, make it active

      var needle = $this.attr('href').replace('/index', '').replace('/modify', '');

      if (current.indexOf(needle) !== -1 && !$this.hasClass('logo')) {
        $this.addClass('active');
      }
    });
  }
};
/**
 * Initialize highlighting the active sidebar menu item.
 */

$(document).ready(function () {
  sidebarMenuShowActive.initialize();
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tYWluL3NpZGViYXItbWVudS1zaG93LWFjdGl2ZS5qcyJdLCJuYW1lcyI6WyJza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0aGlzLnJlbW92ZUNsYXNzKCdhY3RpdmUnKTtcbiAgICAgICAgICAgIC8vIGlmIHRoZSBjdXJyZW50IHBhdGggaXMgbGlrZSB0aGlzIGxpbmssIG1ha2UgaXQgYWN0aXZlXG4gICAgICAgICAgICBjb25zdCBuZWVkbGUgPSAkdGhpcy5hdHRyKCdocmVmJylcbiAgICAgICAgICAgICAgICAucmVwbGFjZSgnL2luZGV4JywgJycpXG4gICAgICAgICAgICAgICAgLnJlcGxhY2UoJy9tb2RpZnknLCAnJyk7XG5cbiAgICAgICAgICAgIGlmIChjdXJyZW50LmluZGV4T2YobmVlZGxlKSAhPT0gLTFcbiAgICAgICAgICAgICAgICAmJiAhJHRoaXMuaGFzQ2xhc3MoJ2xvZ28nKSkge1xuICAgICAgICAgICAgICAgICR0aGlzLmFkZENsYXNzKCdhY3RpdmUnKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSk7XG4gICAgfSxcbn07XG5cblxuLyoqXG4gKiBJbml0aWFsaXplIGhpZ2hsaWdodGluZyB0aGUgYWN0aXZlIHNpZGViYXIgbWVudSBpdGVtLlxuICovXG4kKGRvY3VtZW50KS5yZWFkeSgoKSA9PiB7XG4gICAgc2lkZWJhck1lbnVTaG93QWN0aXZlLmluaXRpYWxpemUoKTtcbn0pO1xuIl19